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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: D = None
        self.o: C = None
        self.txt = txt

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

c.q = f
c.z = f
c.v = m
c.y = e
a.x = m
f.q = a
m.t = d
b.z = d
b.p = m
b.o = h
d.z = b
d.p = m
d.o = f
h.q = a
k.x = m
e.q = f
e.z = f
e.v = m
e.y = c
assert k.x.t.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: D = None
        self.y: A = None
        self.z: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: D = None
        self.o: C = None
        self.txt = txt

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

c.q = f
c.z = f
c.v = m
c.y = e
a.x = m
f.q = a
m.t = d
b.z = d
b.p = m
b.o = h
d.z = b
d.p = m
d.o = f
h.q = a
k.x = m
e.q = f
e.z = f
e.v = m
e.y = c
assert k.x.t.o.q.txt == "a"