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

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

j = A("j")
f = B("f")
d = C("d")
a = D("a")
e = E("e")
l = F("l")

j.r = a
f.r = e
d.r = j
d.q = a
d.s = l
a.z = e
e.s = l
l.t = j
assert d.r.r.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

j = A("j")
f = B("f")
d = C("d")
a = D("a")
e = E("e")
l = F("l")

j.r = a
f.r = e
d.r = j
d.q = a
d.s = l
a.z = e
e.s = l
l.t = j
assert d.r.r.z.s.txt == "l"