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

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.x: D = None
        self.txt = txt

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

i.t = h
i.q = h
n.t = m
n.r = d
a.w = d
a.t = d
a.u = f
a.y = f
m.t = a
m.o = f
m.x = k
d.t = h
d.q = h
c.t = k
c.r = h
f.w = d
f.u = a
f.y = a
f.t = h
k.t = f
k.o = a
k.x = m
h.t = i
h.q = d
assert d.q.q.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.x: D = None
        self.txt = txt

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

i.t = h
i.q = h
n.t = m
n.r = d
a.w = d
a.t = d
a.u = f
a.y = f
m.t = a
m.o = f
m.x = k
d.t = h
d.q = h
c.t = k
c.r = h
f.w = d
f.u = a
f.y = a
f.t = h
k.t = f
k.o = a
k.x = m
h.t = i
h.q = d
assert d.q.q.t.t.txt == "i"