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

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

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

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

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

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

k = A("k")
j = B("j")
b = C("b")
f = D("f")
d = E("d")
g = F("g")
a = B("a")

k.v = g
k.z = f
j.v = d
b.v = j
f.r = a
f.t = b
d.r = k
d.x = b
g.t = b
a.v = d
assert b.v.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.z: D = None
        self.txt = txt

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

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

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

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

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

k = A("k")
j = B("j")
b = C("b")
f = D("f")
d = E("d")
g = F("g")
a = B("a")

k.v = g
k.z = f
j.v = d
b.v = j
f.r = a
f.t = b
d.r = k
d.x = b
g.t = b
a.v = d
assert b.v.v.r.txt == "k"