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

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

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

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

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

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

f.o = h
c.u = h
c.q = m
c.x = m
c.v = d
c.p = f
k.z = f
m.s = h
m.x = f
d.v = k
d.y = m
d.x = c
h.s = m
h.x = f
j.u = m
j.q = m
j.x = m
j.v = d
j.p = f
assert k.z.o.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

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

f.o = h
c.u = h
c.q = m
c.x = m
c.v = d
c.p = f
k.z = f
m.s = h
m.x = f
d.v = k
d.y = m
d.x = c
h.s = m
h.x = f
j.u = m
j.q = m
j.x = m
j.v = d
j.p = f
assert k.z.o.s.x.txt == "f"