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

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

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

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

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

f.r = j
h.y = l
h.z = k
j.t = k
j.o = e
j.x = g
e.y = n
e.q = m
e.p = b
m.r = j
k.y = f
k.z = b
l.r = j
b.y = m
b.z = k
g.t = b
g.o = e
g.x = j
n.r = g
assert l.r.t.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

f.r = j
h.y = l
h.z = k
j.t = k
j.o = e
j.x = g
e.y = n
e.q = m
e.p = b
m.r = j
k.y = f
k.z = b
l.r = j
b.y = m
b.z = k
g.t = b
g.o = e
g.x = j
n.r = g
assert l.r.t.y.r.txt == "j"