class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
c = C("c")
n = D("n")
k = C("k")
b = A("b")
j = B("j")

f.w = b
f.t = k
m.t = j
c.v = b
c.q = b
c.y = f
n.u = f
n.q = c
k.v = b
k.y = f
k.q = f
b.w = f
b.t = c
j.t = m
assert j.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
c = C("c")
n = D("n")
k = C("k")
b = A("b")
j = B("j")

f.w = b
f.t = k
m.t = j
c.v = b
c.q = b
c.y = f
n.u = f
n.q = c
k.v = b
k.y = f
k.q = f
b.w = f
b.t = c
j.t = m
assert j.t.t.t.t.txt == "j"