class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: B = None
        self.w: A = None
        self.p: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: D = None
        self.txt = txt

i = A("i")
j = B("j")
c = C("c")
h = D("h")
k = C("k")
g = A("g")
f = B("f")
a = D("a")

i.y = g
i.q = g
i.w = a
j.p = f
c.y = k
c.p = k
c.q = f
c.w = g
h.r = g
h.u = a
k.y = c
k.p = c
k.q = j
k.w = i
g.y = i
g.q = i
g.w = a
f.p = j
a.r = i
a.u = h
assert j.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: B = None
        self.w: A = None
        self.p: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: D = None
        self.txt = txt

i = A("i")
j = B("j")
c = C("c")
h = D("h")
k = C("k")
g = A("g")
f = B("f")
a = D("a")

i.y = g
i.q = g
i.w = a
j.p = f
c.y = k
c.p = k
c.q = f
c.w = g
h.r = g
h.u = a
k.y = c
k.p = c
k.q = j
k.w = i
g.y = i
g.q = i
g.w = a
f.p = j
a.r = i
a.u = h
assert j.p.p.p.p.p.txt == "f"