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

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

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

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

d.r = l
d.z = a
k.x = a
k.y = f
e.y = b
e.z = l
b.x = k
b.y = d
a.x = b
a.y = f
f.r = a
f.z = a
n.y = l
n.z = l
j.y = k
j.z = k
l.x = b
l.y = d
assert d.r.x.y.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.txt = txt

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

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

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

d.r = l
d.z = a
k.x = a
k.y = f
e.y = b
e.z = l
b.x = k
b.y = d
a.x = b
a.y = f
f.r = a
f.z = a
n.y = l
n.z = l
j.y = k
j.z = k
l.x = b
l.y = d
assert d.r.x.y.z.y.z.txt == "a"