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

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

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

c = A("c")
h = B("h")
j = C("j")
m = A("m")
n = C("n")
i = B("i")
d = C("d")

c.y = d
c.z = d
h.o = j
h.q = i
h.p = d
j.x = m
m.y = j
m.z = d
n.x = c
i.o = n
i.q = h
i.p = d
d.x = c
assert d.x.y.x.y.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: C = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
j = C("j")
m = A("m")
n = C("n")
i = B("i")
d = C("d")

c.y = d
c.z = d
h.o = j
h.q = i
h.p = d
j.x = m
m.y = j
m.z = d
n.x = c
i.o = n
i.q = h
i.p = d
d.x = c
assert d.x.y.x.y.x.y.x.txt == "c"