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

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

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

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

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

h = A("h")
n = B("n")
m = C("m")
k = D("k")
b = E("b")
i = C("i")

h.q = i
n.o = i
m.q = b
k.r = b
k.z = i
b.x = h
i.q = b
assert n.o.q.x.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

h = A("h")
n = B("n")
m = C("m")
k = D("k")
b = E("b")
i = C("i")

h.q = i
n.o = i
m.q = b
k.r = b
k.z = i
b.x = h
i.q = b
assert n.o.q.x.q.q.txt == "b"