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

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

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

g = A("g")
a = B("a")
f = C("f")
m = B("m")
i = C("i")
b = A("b")
h = B("h")
l = A("l")
d = C("d")
j = C("j")

g.x = a
a.t = m
a.o = f
a.w = h
f.u = b
m.t = h
m.w = h
m.o = i
i.u = l
b.x = a
h.t = a
h.w = a
h.o = f
l.x = h
d.u = l
j.u = l
assert d.u.x.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

g = A("g")
a = B("a")
f = C("f")
m = B("m")
i = C("i")
b = A("b")
h = B("h")
l = A("l")
d = C("d")
j = C("j")

g.x = a
a.t = m
a.o = f
a.w = h
f.u = b
m.t = h
m.w = h
m.o = i
i.u = l
b.x = a
h.t = a
h.w = a
h.o = f
l.x = h
d.u = l
j.u = l
assert d.u.x.o.u.txt == "b"