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

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

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

class D:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

a = A("a")
d = B("d")
k = C("k")
g = D("g")
j = D("j")
b = B("b")
f = D("f")
n = A("n")
h = C("h")

a.u = k
a.t = n
d.u = j
d.r = k
d.q = k
d.z = h
k.r = n
k.x = f
k.q = b
g.v = f
j.v = f
b.u = g
b.r = k
b.z = k
b.q = h
f.v = j
n.u = k
n.t = a
h.r = n
h.x = f
h.q = b
assert b.u.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

a = A("a")
d = B("d")
k = C("k")
g = D("g")
j = D("j")
b = B("b")
f = D("f")
n = A("n")
h = C("h")

a.u = k
a.t = n
d.u = j
d.r = k
d.q = k
d.z = h
k.r = n
k.x = f
k.q = b
g.v = f
j.v = f
b.u = g
b.r = k
b.z = k
b.q = h
f.v = j
n.u = k
n.t = a
h.r = n
h.x = f
h.q = b
assert b.u.v.v.v.v.v.v.v.txt == "f"