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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

a = A("a")
d = B("d")
c = C("c")
j = D("j")
e = E("e")
i = F("i")

a.o = i
d.s = e
d.q = e
d.t = a
c.o = d
c.y = e
j.z = a
e.p = c
i.q = e
assert c.o.s.p.y.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

a = A("a")
d = B("d")
c = C("c")
j = D("j")
e = E("e")
i = F("i")

a.o = i
d.s = e
d.q = e
d.t = a
c.o = d
c.y = e
j.z = a
e.p = c
i.q = e
assert c.o.s.p.y.p.o.txt == "d"