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

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

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

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

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

d = A("d")
n = B("n")
h = C("h")
l = D("l")
g = E("g")
k = B("k")
b = D("b")

d.x = h
d.q = n
n.x = k
n.t = k
n.p = k
n.u = h
h.t = k
l.w = n
g.t = h
k.x = n
k.t = n
k.p = n
k.u = h
b.w = n
assert h.t.p.x.t.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: B = None
        self.txt = txt

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

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

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

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

d = A("d")
n = B("n")
h = C("h")
l = D("l")
g = E("g")
k = B("k")
b = D("b")

d.x = h
d.q = n
n.x = k
n.t = k
n.p = k
n.u = h
h.t = k
l.w = n
g.t = h
k.x = n
k.t = n
k.p = n
k.u = h
b.w = n
assert h.t.p.x.t.t.p.txt == "n"