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

class B:
    def __init__(self, txt: str):
        self.w: F = None
        self.p: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: B = None
        self.o: B = None
        self.p: E = None
        self.txt = txt

g = A("g")
b = B("b")
d = C("d")
c = D("c")
a = E("a")
i = F("i")

g.r = i
b.w = i
b.p = i
d.t = c
c.t = g
a.r = g
a.z = i
i.v = c
i.u = b
i.o = b
i.p = a
assert b.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: F = None
        self.p: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: B = None
        self.o: B = None
        self.p: E = None
        self.txt = txt

g = A("g")
b = B("b")
d = C("d")
c = D("c")
a = E("a")
i = F("i")

g.r = i
b.w = i
b.p = i
d.t = c
c.t = g
a.r = g
a.z = i
i.v = c
i.u = b
i.o = b
i.p = a
assert b.w.v.t.txt == "g"