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

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

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

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

f = A("f")
c = B("c")
b = C("b")
a = D("a")
i = A("i")
h = D("h")
k = A("k")
e = A("e")
d = A("d")
m = C("m")

f.t = i
f.u = c
f.w = e
f.r = a
c.p = b
c.q = h
c.w = m
b.u = f
b.t = i
a.q = c
i.t = f
i.u = c
i.w = e
i.r = a
h.q = c
k.t = e
k.u = c
k.w = f
k.r = h
e.t = k
e.u = c
e.w = i
e.r = a
d.t = e
d.u = c
d.w = k
d.r = h
m.u = i
m.t = e
assert c.q.q.q.q.p.t.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: B = None
        self.w: A = None
        self.r: D = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
b = C("b")
a = D("a")
i = A("i")
h = D("h")
k = A("k")
e = A("e")
d = A("d")
m = C("m")

f.t = i
f.u = c
f.w = e
f.r = a
c.p = b
c.q = h
c.w = m
b.u = f
b.t = i
a.q = c
i.t = f
i.u = c
i.w = e
i.r = a
h.q = c
k.t = e
k.u = c
k.w = f
k.r = h
e.t = k
e.u = c
e.w = i
e.r = a
d.t = e
d.u = c
d.w = k
d.r = h
m.u = i
m.t = e
assert c.q.q.q.q.p.t.u.p.txt == "b"