class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: D = 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.q: C = None
        self.txt = txt

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

l = A("l")
d = B("d")
j = C("j")
f = D("f")
b = C("b")
e = D("e")
g = B("g")
a = D("a")
k = D("k")
n = A("n")

l.y = g
l.o = k
d.x = n
j.q = b
f.t = g
f.s = n
f.y = d
b.q = j
e.t = d
e.s = l
e.y = g
g.x = n
a.t = g
a.s = n
a.y = d
k.t = g
k.s = l
k.y = d
n.y = g
n.o = k
assert f.y.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: D = 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.q: C = None
        self.txt = txt

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

l = A("l")
d = B("d")
j = C("j")
f = D("f")
b = C("b")
e = D("e")
g = B("g")
a = D("a")
k = D("k")
n = A("n")

l.y = g
l.o = k
d.x = n
j.q = b
f.t = g
f.s = n
f.y = d
b.q = j
e.t = d
e.s = l
e.y = g
g.x = n
a.t = g
a.s = n
a.y = d
k.t = g
k.s = l
k.y = d
n.y = g
n.o = k
assert f.y.x.y.x.txt == "n"