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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: D = None
        self.u: D = None
        self.q: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: A = None
        self.p: C = None
        self.r: A = None
        self.txt = txt

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

g.u = j
c.t = l
c.p = l
c.u = l
c.q = h
k.z = g
k.q = c
l.z = h
l.v = j
l.p = k
l.r = g
j.u = g
i.z = j
i.q = c
f.t = l
f.q = l
f.p = h
f.u = h
h.z = l
h.v = g
h.p = i
h.r = j
assert i.q.u.v.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: D = None
        self.u: D = None
        self.q: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: A = None
        self.p: C = None
        self.r: A = None
        self.txt = txt

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

g.u = j
c.t = l
c.p = l
c.u = l
c.q = h
k.z = g
k.q = c
l.z = h
l.v = j
l.p = k
l.r = g
j.u = g
i.z = j
i.q = c
f.t = l
f.q = l
f.p = h
f.u = h
h.z = l
h.v = g
h.p = i
h.r = j
assert i.q.u.v.u.u.u.u.u.txt == "g"