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

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

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

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

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

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

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

a.w = g
a.x = j
d.r = g
d.y = g
d.w = f
d.o = f
g.q = l
g.p = d
f.z = d
f.q = d
l.o = d
l.q = j
j.r = a
assert j.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

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

a.w = g
a.x = j
d.r = g
d.y = g
d.w = f
d.o = f
g.q = l
g.p = d
f.z = d
f.q = d
l.o = d
l.q = j
j.r = a
assert j.r.x.r.txt == "a"