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

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

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

h = A("h")
d = B("d")
j = C("j")
b = B("b")
c = A("c")
l = C("l")
g = C("g")
n = C("n")

h.o = n
h.y = d
h.p = b
d.t = h
j.x = h
b.t = c
c.o = l
c.y = b
c.p = b
l.x = c
g.x = c
n.x = h
assert h.o.x.y.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: B = None
        self.p: B = None
        self.txt = txt

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

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

h = A("h")
d = B("d")
j = C("j")
b = B("b")
c = A("c")
l = C("l")
g = C("g")
n = C("n")

h.o = n
h.y = d
h.p = b
d.t = h
j.x = h
b.t = c
c.o = l
c.y = b
c.p = b
l.x = c
g.x = c
n.x = h
assert h.o.x.y.t.o.txt == "n"