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

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

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

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

g = A("g")
h = B("h")
b = C("b")
k = D("k")
j = D("j")
c = A("c")
f = A("f")
l = B("l")

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

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

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

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

g = A("g")
h = B("h")
b = C("b")
k = D("k")
j = D("j")
c = A("c")
f = A("f")
l = B("l")

g.y = h
g.t = b
g.r = c
h.o = k
b.y = h
k.r = l
k.x = b
j.r = l
j.x = b
c.y = l
c.t = b
c.r = g
f.y = l
f.t = b
f.r = g
l.o = j
assert j.x.y.o.x.txt == "b"