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

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

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

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

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

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

f.p = k
c.o = f
k.z = f
k.q = a
k.x = a
a.w = f
a.u = d
a.q = c
a.p = k
d.w = k
h.o = f
assert c.o.p.z.p.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

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

f.p = k
c.o = f
k.z = f
k.q = a
k.x = a
a.w = f
a.u = d
a.q = c
a.p = k
d.w = k
h.o = f
assert c.o.p.z.p.x.w.txt == "f"