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

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

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

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

l.y = c
l.u = a
l.o = a
h.x = a
g.x = d
g.r = n
c.x = d
c.r = n
a.y = b
a.u = l
a.o = l
n.x = l
b.x = n
b.r = n
d.x = l
assert l.y.x.x.o.o.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.u: A = None
        self.o: A = None
        self.txt = txt

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

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

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

l.y = c
l.u = a
l.o = a
h.x = a
g.x = d
g.r = n
c.x = d
c.r = n
a.y = b
a.u = l
a.o = l
n.x = l
b.x = n
b.r = n
d.x = l
assert l.y.x.x.o.o.y.x.x.txt == "l"